#ifndef COLLECTIONITEMMODEL_H
#define COLLECTIONITEMMODEL_H

#include <QStandardItemModel>

#include "collection/collection.h"
#include "trackinfo.h"

namespace Playur {

class TrackItem : public QStandardItem
{
public:
  TrackItem(const QString& title, const QString& url);
  void exec(QWidget* source);
  
private:
  QString url;
};

class ListProxy : public QAbstractItemModel
{
Q_OBJECT
    friend class CollectionItemModel;

protected:
    ListProxy(QList<Playur::TrackInfo> *list);
    
public:
    QModelIndex parent(const QModelIndex & index) const;
    int rowCount(const QModelIndex & parent = QModelIndex()) const;
    int columnCount(const QModelIndex & parent = QModelIndex()) const;
    QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
    QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
    
public slots:
    void updateProxy();
    
private:
    QList<Playur::TrackInfo> *list;
};

class CollectionItemModel : public QStandardItemModel
{
Q_OBJECT
public:
    CollectionItemModel(QObject* parent = 0);
    void setFilter(const QString& filter);
    QAbstractItemModel *getListProxy();

public slots:
    void addCollection(const QString& xml, const QString& overrideAddress = "");
    
signals:
    void updateProxies();

private:
    QList<Collection*> collections;
    QList<Playur::TrackInfo> rawList;
};

}

#endif // COLLECTIONITEMMODEL_H
